import matplotlib.pyplot as plt
from die import Die

# print(plt.style.available)
# plt.style.use('seaborn-v0_8-talk')
# 指定默认字体
plt.rcParams['font.family'] = 'Kai'  # 或其他支持中文的字体
plt.rcParams['axes.unicode_minus'] = False  # 解决负号'-'显示为方块的问题

die_1 = Die(6)
die_2 = Die(6)
die_3 = Die(6)

results = [die_1.roll() * die_2.roll() for _ in range(1000)]

print(results)

# 分析结果
max_number_side = die_1.number_side * die_2.number_side 
frequencies = [results.count(num_die) for num_die in range(1, max_number_side+1)]
print(f'抛掷次数={frequencies}')

x_values = list(range(1, max_number_side+1))

fig, ax = plt.subplots()

# ax.scatter(x_values, frequencies, c=frequencies, cmap=plt.cm.Blues, s=10)
ax.plot(x_values, frequencies, linewidth=3)

# 设置图标标题
ax.set_title('抛掷筛子', fontsize = 24)
ax.set_xlabel('抛掷结果', fontsize = 24)
ax.set_ylabel('抛掷面数', fontsize = 24)
ax.tick_params(axis='both', labelsize=14)

plt.show()